Polygons#
Download this notebook from GitHub (right-click to download).
import hvplot.pandas # noqa
Using hvplot with geopandas is as simple as loading a geopandas dataframe and calling hvplot on it with geo=True.
import geopandas as gpd
countries = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
countries.sample(5)
| pop_est | continent | name | iso_a3 | gdp_md_est | geometry | |
|---|---|---|---|---|---|---|
| 20 | 3398.0 | South America | Falkland Is. | FLK | 282 | POLYGON ((-61.20000 -51.85000, -60.00000 -51.2... |
| 73 | 1148130.0 | Africa | eSwatini | SWZ | 4471 | POLYGON ((32.07167 -26.73382, 31.86806 -27.177... |
| 102 | 216565318.0 | Asia | Pakistan | PAK | 278221 | POLYGON ((77.83745 35.49401, 76.87172 34.65354... |
| 142 | 5818553.0 | Europe | Denmark | DNK | 350104 | MULTIPOLYGON (((9.92191 54.98310, 9.28205 54.8... |
| 0 | 889953.0 | Oceania | Fiji | FJI | 5496 | MULTIPOLYGON (((180.00000 -16.06713, 180.00000... |
countries.hvplot(geo=True)
Control the color of the elements using the c option.
countries.hvplot.polygons(geo=True, c='pop_est', hover_cols='all')
You can even color by another series, such as population density:
countries.hvplot.polygons(geo=True, c=countries.pop_est/countries.area, clabel='pop density')
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.
Download this notebook from GitHub (right-click to download).